package org.magnerfuller.imtoolkit.util;

import java.io.*;
import java.net.SocketException;

public class Hose extends Thread {

  protected InputStream source;
  
  protected OutputStream sink;

  protected int buffSize;

  public Hose(InputStream source, OutputStream sink, int buffSize) {
    super();

    if(source == null) throw new IllegalArgumentException("Hose: source is null!");
    if(sink == null) throw new IllegalArgumentException("Hose: sink is null!");
    
    this.source = source;
    this.sink = sink;
    this.buffSize = buffSize;

  }//Hose

  public void run() {
    int ch;
    try {
      while((ch = source.read()) != -1) {
        sink.write(ch);
        sink.flush();
      }
      
      sink.close();
    } catch(IOException e) {
      // Don't really need this that I can tell.
    }

  }

}
